﻿<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common/meta.jsp"%>
<%@ include file="/common/content.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>添加广告信息</title>
		<script>
	$(document).ready(function(){
		$("#names").focus();
		$("#epAdForm").validate({
			 rules: { 
				title: { 
        			required: true, 
        			maxlength:50
    			},
            	address: {
                    required: true ,
                    url:true,
			        maxlength:100
        	    },
        	    orderColumn:{
        	    	required: true ,
        	    	number:true
        	    },
        	    frontNum:{
        	    	maxlength:20
        	    },
            	intro: {
                    required: true ,
			        maxlength:5000
        	    },
            	cost: {
                    required: true ,
			        maxlength:50
        	    },
            	clientName: {
                    required: true ,
			        maxlength:50
        	    }
			},
			success: function(label) {
				label.html("&nbsp;").addClass("checked");
	        }	
		});
		
		document.getElementById("imgchange").rel=$("#imgShowTeacherPhoto").attr("src");
	});		
	//当选择图片时发生
	function doSelectPhotoChanged(){
		filePath = document.getElementById("upload").value;
		if(checkFileUpload(filePath)){
		  document.getElementById("upload").value = "";
		  document.getElementById("imgShowTeacherPhoto").src=filePath;
		  document.getElementById("imgchange").rel=$("#imgShowTeacherPhoto").attr("src");
		}
	}
	
	//文件上传验证
	function checkFileUpload()
	{
	  var path = document.getElementById("upload").value;
	  if(!sy_FilterFile(path,"jpg,gif,bmp,png,jpeg")){
	    alert("文件类型不正确，请上传正确的格式！\n(jpg,gif,bmp,png,jpeg)");
	    return false;
	  }
	  if(sy_GetImageToGetSize(path).fileSize>1024000){
	    alert("上传文件大小不能够超过1MB！");
	    return false;
	  }
	  return true;
	}
	//提交表单前验证准备上传的文件
	function doBeforeSubmit(){
		if(document.getElementById("upload").value!=""){
			if(!checkFileUpload()){
				return false;
			}
		}
	}
</script>

	</head>
	<body>
		<div class="rhead">
			<div class="rpos">
				当前位置: 互动管理 - 广告信息管理 - 修改广告信息
			</div>
			<div class="ropt">
				<input type="button" value="返回" onclick="history.back()" />
			</div>
			<div class="clear"></div>
		</div>
		<form action="enterpriseAdAction!update.action" method="post"
			id="epAdForm" name="epAdForm" enctype="multipart/form-data"
			method="post">
			<input type="hidden" name="id" value="${enterpriseAd.id}" />
			<table align="center" class="listTable3">
				<tr>
					<td width="100px" class="pn-flabel">
						广告名称
					</td>
					<td>
						<input type="text" name="names" size="100"
							value="${enterpriseAd.names}" />
					</td>
				</tr>
				<tr>
					<td class="pn-flabel">
						广告标识
					</td>
					<td>
						<input type="text" name="frontNum"
							value="${enterpriseAd.frontNum}" />
					</td>
				</tr>
				<tr>
					<td class="pn-flabel">
						广告排序
					</td>
					<td>
						<input type="text" name="orderColumn"
							value="${enterpriseAd.orderColumn}" />
					</td>
				</tr>
				<tr>
					<td class="pn-flabel">
						广告图片
					</td>
					<td>
					<input type="hidden" name="oldUploadFileName" value="${enterpriseAd.photo}"/>
						<a href="${ctx}/upload/enterprice/${enterpriseAd.photo}"
							target="_blank" name="imgchange" id="imgchange"
							class="screenshot" rel="doSelectPhotoChanged()"><img
								id="imgShowTeacherPhoto" name="imgShowTeacherPhoto" border="0"
								width="96"
								src="
										<c:choose>
											<c:when test="${empty enterpriseAd.photo}">
													${ctx}/upload/MissPhoto.JPG
											</c:when>
											<c:otherwise>
												${ctx}/upload/enterprice/${enterpriseAd.photo}
											</c:otherwise>
										</c:choose>
										" />
						</a>
						<br />
						<input type="file" id="upload" name="upload"
							onChange="doSelectPhotoChanged();" size="30" />
					</td>
				</tr>
				<tr>
					<td class="pn-flabel">
						广告链接地址
					</td>
					<td>
						<input type="text" name="address" size="100"
							value="${enterpriseAd.address}" />
					</td>
				</tr>
				<tr>
					<td class="pn-flabel">
						广告简介
					</td>
					<td>
						<textarea rows="10" cols="100" name="intro">${enterpriseAd.intro}</textarea>
				</tr>
				<tr>
					<td class="pn-flabel">
						广告费用
					</td>
					<td>
						<input type="text" name="acost" value="${enterpriseAd.acost}" />
					</td>
				</tr>
				<tr>
					<td class="pn-flabel">
						客户名称
					</td>
					<td>
						<input type="text" name="clientName"
							value="${enterpriseAd.clientName}" />
					</td>
				</tr>
				<tr>
					<td class="pn-flabel">
						显示时间
					</td>
					<td>
						<input type="text" name="initTime" onchange="checkDate()"
							id="initTime"
							value="<fmt:formatDate value="${enterpriseAd.initTime}" 
					pattern="yyyy-MM-dd"/>"
							readonly />
						<input id="starttimeBt" type="button" class="default_button"
							value="选择" />
						<script type="text/javascript">
						Calendar.setup({
							inputField     : "initTime",
							button	  	   : "starttimeBt",
							/*ifFormat       :    "%Y-%m-%d %H:%M",							
					        showsTime      :    true,
					        timeFormat     :    "24"*/
							ifFormat       :    "%Y-%m-%d"
						});
					</script>
						至
						<input type="text" name="endTime" onchange="checkDate()"
							id="endTime"
							value="<fmt:formatDate value="${enterpriseAd.endTime}" 
					pattern="yyyy-MM-dd"/>"
							readonly />
						<input id="endtimeBt" type="button" class="default_button"
							value="选择" />
						<script type="text/javascript">
						Calendar.setup({
							inputField     : "endTime",
							button	  	   : "endtimeBt",
							/*ifFormat       :    "%Y-%m-%d %H:%M",							
					        showsTime      :    true,
					        timeFormat     :    "24"*/
							ifFormat       :    "%Y-%m-%d"
						});
					</script>
					</td>
				</tr>
				<tr>
					<td class="pn-flabel">
						状态
					</td>
					<td>
						<select name="enterpriseAd.state">
							<option value="1">
								已启用
							</option>
							<option value="0"
								<c:if test="${enterpriseAd.state==0}">selected</c:if>>
								已停用
							</option>
						</select>
					</td>
				</tr>
				<tr>
					<td colspan="2" style="text-align: center">
						<input type="submit" value=" 提 交 " />
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>

